import java.util.*;

public class Doudizhu {
    private List<Card> list = new ArrayList<>();
    private String[] points = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
    private String[] flowers = {"❤", "♣", "♦", "♠"};

    // 初始化54张扑克牌
    public void init() {
        for (int i = 0; i < points.length; i++) {
            for (int j = 0; j < flowers.length; j++) {
                //将带花色的扑克牌加入集合
                list.add(new Card(points[i], flowers[j], i));

            }
        }
        list.add(new Card("小王", null, 50));
        list.add(new Card("大王", null, 99));
        System.out.println(list);
    }

    // 洗牌
    public void xipai() {
        Collections.shuffle(list);
        System.out.println(list);
    }

    // 发牌
    public void fapai() {
        List one = list.subList(0, 17);
        one.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                return o2.getValue() - o1.getValue();
            }
        });

        List two = list.subList(17, 34);
        two.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                return o2.getValue() - o1.getValue();
            }
        });
        List three = list.subList(34, 51);
        three.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                return o2.getValue() - o1.getValue();
            }
        });
        List bottom = list.subList(51, 54);
        System.out.println(one);
        System.out.println(two);
        System.out.println(three);
        System.out.println(bottom);
    }


    public static void main(String[] args) {
        Doudizhu a = new Doudizhu();
        a.init();
        a.xipai();
        a.fapai();
    }
}
